function getConstellation(dateString) {
    let d1 = new Date(dateString);
    let month = d1.getMonth() + 1;
    let day = d1.getDate();
    var s = "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
    var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
    let outputString = s.substr(month * 2 - (day < arr[month - 1] ? 2 : 0), 2);
    return outputString;
}

function getAge(dateString) {
    let d1 = new Date(dateString);
    let d2 = new Date();
    let minusYear = d2.getFullYear() - d1.getFullYear();
    let minusMonth = d2.getMonth() - d1.getMonth();
    let minusDate = d2.getDate() - d1.getDate();
    if (minusMonth < 0 || (minusMonth == 0 && minusDate < 0)) {
        minusYear = minusYear - 1;
    }
    let age = minusYear;
    return age;
}

function getTimeString(timestamp)   
{ 
  let time = new Date(Number(timestamp));
  let Y = time.getFullYear();
  let M = time.getMonth()+1;
  let D = time.getDate();
  let H = time.getHours();
  let I = time.getMinutes();
  let S = time.getSeconds();
  let timeString = Y+'-'+M+'-'+D+' '+H+':'+I+':'+S;
  return timeString;
}

function getShortTimeString(timestamp)   
{ 
  let time = new Date(Number(timestamp));
  let M = time.getMonth()+1;
  let D = time.getDate();
  let H = time.getHours();
  let I = time.getMinutes();
  let timeString = M+'/'+D+' '+H+':'+I;
  return timeString;
}

export default {
    getConstellation,
    getAge,
    getTimeString,
    getShortTimeString
}